package cn.wolfcode.shop.cloud.util;

import cn.wolfcode.shop.cloud.common.CodeMsg;
import lombok.Getter;
import lombok.Setter;

import java.text.MessageFormat;

@Getter
@Setter
public class MemberCodeMsg extends CodeMsg {

    public static final MemberCodeMsg PARAM_NOT_EMPTY = new MemberCodeMsg("账号或密码不能为空",50101);
    public static final MemberCodeMsg LOGIN_ERROR = new MemberCodeMsg("账号或密码不匹配",50101);
    public static final MemberCodeMsg PARAM_VALIDATION = new MemberCodeMsg("参数异常:{0}",50103);

    public MemberCodeMsg(String msg, int code) {
        super(msg, code);
    }

    public MemberCodeMsg() {
    }

    public CodeMsg format(String msg) {
        MemberCodeMsg memberCodeMsg = new MemberCodeMsg();
        memberCodeMsg.setCode(this.getCode());
        memberCodeMsg.setMsg(MessageFormat.format(this.getMsg(), msg));
        return memberCodeMsg;
    }

}
